package com.lemo.mp.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.lemo.mp.model.Demo;
import com.lemo.mp.service.IDemoService;

@RestController
@RequestMapping("/lemo")
public class DemoController {

	@Autowired
	private IDemoService ds;
	

	@RequestMapping("/insertDemo")
	public Demo insertDemo() {
		Demo demo = new Demo();
//		demo.setId(UUID.randomUUID().toString());
		demo.setName(Thread.currentThread().getName());
		ds.insert(demo);
		return demo;
	}

	@RequestMapping("/selectByMap1")
	public List<Demo> selectByMap() {
		Map<String, Object> columnMap = new HashMap<String, Object>();
		columnMap.put("id", "c4147d53-92aa-4fc6-8112-919f00cd3695");
		List<Demo> selectByMap = ds.selectByMap(columnMap);
		return selectByMap;
	}

	@RequestMapping("/selectPage1")
	public Page<Demo> selectPage() {
		Page<Demo> page = new Page<Demo>(5553, 20);
		return ds.selectPage(page, null);
	}

}
